package com.ruoyi.worker.constant;

/**
 * @author: 陈宇寰
 * @date: 2021-12-26 00:28:31
 * @params:
 * @return:
 * @description: 考勤结果枚举
 */
public enum AttendanceSignResultEnum {

    SIGN_TYPE_UP_WORK("上班", 1),
    SIGN_TYPE_DOWN_WORK("下班", 2),
    SIGN_WORK_TYPE_DAY_WORK("白班", 1),
    SIGN_WORK_TYPE_NIGHT_WORK("夜班", 2),
    SIGN_WORK_TYPE_CROSS_WORK("通班", 3),
    SIGN_RESULT_NORMAL("正常", 1),
    SIGN_RESULT_ABSENT("缺卡", 2),
    SIGN_RESULT_WORK_INJURE("工伤", 3),
    SIGN_RESULT_VACATE("离职", 4),
    SIGN_RESULT_LEAVE("请假", 5),
    SIGN_RESULT_ABSENTEEISM("旷工", 6),
    SIGN_RESULT_LATE("普通迟到", 7),
    SIGN_RESULT_NORMAL_LATE("一般迟到", 8),
    SIGN_RESULT_SERIOUSLY_LATE("严重迟到", 9),
    SIGN_RESULT_HOLIDAY("休息", 10),
    SIGN_RESULT_LEAVE_EARLY("早退", 11);

    private String name;
    private Integer code;

    AttendanceSignResultEnum(String name, Integer code) {
        this.name = name;
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public static <T extends AttendanceSignResultEnum> String getNameByCode(Class<T> clazz, int code) {
        for (T inner : clazz.getEnumConstants()) {
            if (inner.name().startsWith("SIGN_RESULT") && code == inner.getCode()) {
                return inner.getName();
            }
        }
        return null;
    }
}
